* Intra-Industry Trade, Global Value Chains, and the Political Economy of Selective Trade Protection *

************************* Table 2 ********************************************

use "STP Dataset Final.dta", clear

gen TradeBarrier = 1 if TradeBarrierCount>0
replace TradeBarrier = 0 if TradeBarrierCount==0
gen Trade_importance = ((ImportT1 + ExportT1)/(ImportCountryT1 + ExportCountryT1))*100
drop if ImportincreaseT1T2 ==.
gen importincrease = 1 if ImportincreaseT1T2>=0
replace importincrease = 0 if ImportincreaseT1T2<0
gen importsurge75 = 1 if ImportincreaseT1T2>=75
replace importsurge75 = 0 if ImportincreaseT1T2<75
gen importsurge45 = 1 if ImportincreaseT1T2>=45
replace importsurge45 = 0 if ImportincreaseT1T2<45
gen HomRaw = 1 if RawMaterials==1 & Rauchcon==0
replace HomRaw=0 if RawMaterials==0 | Rauchcon==1
replace HomRaw=. if RawMaterials==. | Rauchcon==.

heckprobit SelectiveProtection IITt1 GVC i.Countryid i.Sector, sel(TradeBarrier= importincrease i.Countryid i.Sector) vce(robust) first

heckprobit SelectiveProtection IITt1 GVC importsurge45 ib3.Government PTAs i.Countryid i.Sector, sel(TradeBarrier= importincrease ib3.Government TariffAHSWAAll Trade_importance i.Countryid i.Sector) vce(robust) first

heckprobit SelectiveProtection IITt1 GVC  importsurge75 ib3.Government PTAs  i.Countryid i.Sector, sel(TradeBarrier=  importincrease IITt1 GVC ib3.Government TariffAHSWAAll Trade_importance HomRaw i.Countryid i.Sector) vce(robust) first

keep if Countryid==8
heckprobit SelectiveProtection IITt1 IntrafirmT1 importsurge45 ib3.Government PTAs i.Sector, sel(TradeBarrier=  importincrease IITt1 IntrafirmT1 ib3.Government TariffAHSWAAll Trade_importance HomRaw i.Sector) vce(robust) first 

******************************* Appendix **************************************************

************************* Table A.4 ********************************************

use "STP Dataset Final.dta", clear

gen TradeBarrier = 1 if TradeBarrierCount>0
replace TradeBarrier = 0 if TradeBarrierCount==0
gen Trade_importance = ((ImportT1+ExportT1)/(ImportCountryT1+ExportCountryT1))*100
drop if ImportincreaseT1T2 ==.
gen importincrease = 1 if ImportincreaseT1T2>=0
replace importincrease = 0 if ImportincreaseT1T2<0
gen importsurge75 = 1 if ImportincreaseT1T2>=75
replace importsurge75 = 0 if ImportincreaseT1T2<75
gen importsurge45 = 1 if ImportincreaseT1T2>=45
replace importsurge45 = 0 if ImportincreaseT1T2<45
gen HomRaw = 1 if RawMaterials==1 & Rauchcon==0
replace HomRaw=0 if RawMaterials==0 | Rauchcon==1
replace HomRaw=. if RawMaterials==. | Rauchcon==.
drop if TradeBarrier == 0

probit SelectiveProtection IITt1 GVC importincrease i.Countryid i.Sector, vce(robust) 

probit SelectiveProtection IITt1 GVC importsurge45 ib3.Government PTAs importincrease TariffAHSWAAll Trade_importance i.Countryid i.Sector, vce(robust) 

probit SelectiveProtection IITt1 GVC importsurge75 ib3.Government PTAs importincrease TariffAHSWAAll Trade_importance HomRaw i.Countryid i.Sector, vce(robust) 

************************* Table A.5  ********************************************
use "STP Dataset Final.dta", clear

* Column 1: Policy substitution
gen TradeBarrier = 1 if TradeBarrierCount>0
replace TradeBarrier = 0 if TradeBarrierCount==0
gen Trade_importance = ((ImportT1+ExportT1)/(ImportCountryT1+ExportCountryT1))*100
drop if ImportincreaseT1T2 ==.
gen importincrease = 1 if ImportincreaseT1T2>=0
replace importincrease = 0 if ImportincreaseT1T2<0
gen importsurge75 = 1 if ImportincreaseT1T2>=75
replace importsurge75 = 0 if ImportincreaseT1T2<75
gen importsurge45 = 1 if ImportincreaseT1T2>=45
replace importsurge45 = 0 if ImportincreaseT1T2<45
gen Overhang = 1 if BindingoverhangWAAll>0
replace Overhang = 0 if BindingoverhangWAAll<=0
drop if BindingoverhangWAAll==.

heckprobit SelectiveProtection IITt1 GVC importsurge45  ib3.Government PTAs Overhang i.Countryid i.Sector, sel(TradeBarrier=  importincrease IITt1 GVC ib3.Government TariffAHSWAAll Trade_importance Overhang i.Countryid i.Sector) vce(robust) first

* Column 2: Populist era 
use "STP Dataset Final.dta", clear

gen TradeBarrier = 1 if TradeBarrierCount>0
replace TradeBarrier = 0 if TradeBarrierCount==0
gen Trade_importance = ((ImportT1+ExportT1)/(ImportCountryT1+ExportCountryT1))*100
drop if ImportincreaseT1T2 ==.
gen importincrease = 1 if ImportincreaseT1T2>=0
replace importincrease = 0 if ImportincreaseT1T2<0
gen importsurge75 = 1 if ImportincreaseT1T2>=75
replace importsurge75 = 0 if ImportincreaseT1T2<75
gen importsurge45 = 1 if ImportincreaseT1T2>=45
replace importsurge45 = 0 if ImportincreaseT1T2<45
drop if TariffAHSWAAll==.
gen Populist = 1 if Year>2016
replace Populist = 0 if Year<2017

heckprobit SelectiveProtection IITt1 GVC Populist importsurge45  ib3.Government PTAs  i.Countryid i.Sector, sel(TradeBarrier=  importincrease Populist IITt1 GVC ib3.Government TariffAHSWAAll Trade_importance i.Countryid i.Sector) vce(robust) first

* Column 3: Excl. China-specific  
use "STP Dataset Final.dta", clear

gen TradeBarrier = 1 if TradeBarrierCount>0
replace TradeBarrier = 0 if TradeBarrierCount==0
gen Trade_importance = ((ImportT1+ExportT1)/(ImportCountryT1+ExportCountryT1))*100
drop if ImportincreaseT1T2 ==.
gen importincrease = 1 if ImportincreaseT1T2>=0
replace importincrease = 0 if ImportincreaseT1T2<0
gen importsurge75 = 1 if ImportincreaseT1T2>=75
replace importsurge75 = 0 if ImportincreaseT1T2<75
gen importsurge45 = 1 if ImportincreaseT1T2>=45
replace importsurge45 = 0 if ImportincreaseT1T2<45
drop if TariffAHSWAAll==.
drop if ChinaSpecific==1

heckprobit SelectiveProtection IITt1 GVC importsurge45  ib3.Government PTAs  i.Countryid i.Sector, sel(TradeBarrier=  importincrease IITt1 GVC ib3.Government TariffAHSWAAll Trade_importance i.Countryid i.Sector) vce(robust) first

* Column 4: Excl. Contingency
use "STP Dataset Final.dta", clear

gen TradeBarrier = 1 if TradeBarrierCount>0
replace TradeBarrier = 0 if TradeBarrierCount==0
gen Trade_importance = ((ImportT1+ExportT1)/(ImportCountryT1+ExportCountryT1))*100
drop if ImportincreaseT1T2 ==.
gen importincrease = 1 if ImportincreaseT1T2>=0
replace importincrease = 0 if ImportincreaseT1T2<0
gen importsurge75 = 1 if ImportincreaseT1T2>=75
replace importsurge75 = 0 if ImportincreaseT1T2<75
gen importsurge45 = 1 if ImportincreaseT1T2>=45
replace importsurge45 = 0 if ImportincreaseT1T2<45
drop if TariffAHSWAAll==.

drop if Duration<1826 & Contingency==1

heckprobit SelectiveProtection IITt1 GVC importsurge45  ib3.Government PTAs  i.Countryid i.Sector, sel(TradeBarrier=  importincrease IITt1 GVC ib3.Government TariffAHSWAAll Trade_importance  i.Countryid i.Sector) vce(robust) first

************************* Table A.6  ********************************************

use "STP Dataset Final.dta", clear

gen TradeBarrier = 1 if TradeBarrierCount>0
replace TradeBarrier = 0 if TradeBarrierCount==0
gen Trade_importance = ((ImportT1+ExportT1)/(ImportCountryT1+ExportCountryT1))*100
drop if ImportincreaseT1T2 ==.
gen importincrease = 1 if ImportincreaseT1T2>=0
replace importincrease = 0 if ImportincreaseT1T2<0
gen importsurge75 = 1 if ImportincreaseT1T2>=75
replace importsurge75 = 0 if ImportincreaseT1T2<75
gen importsurge45 = 1 if ImportincreaseT1T2>=45
replace importsurge45 = 0 if ImportincreaseT1T2<45
gen HomRaw = 1 if RawMaterials==1 & Rauchcon==0
replace HomRaw=0 if RawMaterials==0 | Rauchcon==1
replace HomRaw=. if RawMaterials==. | Rauchcon==.
gen choice = 1 if TradeBarrier==0
replace choice = 2 if SelectiveProtection ==1
replace choice = 3 if GeneralProtection ==1
replace choice = 4 if GeneralProtection ==1 & SelectiveProtection ==1
drop if choice==4

mprobit choice IITt1 GVC importincrease i.Countryid i.Sector, vce(cl Countryid) 

mprobit choice IITt1 GVC  ib3.Government PTAs importincrease  TariffAHSWAAll Trade_importance i.Countryid i.Sector,  vce(cl Countryid) 

mprobit choice IITt1 GVC importsurge45 ib3.Government PTAs TariffAHSWAAll Trade_importance HomRaw i.Countryid i.Sector, vce(cl Countryid) 

************************* Table A.7 ********************************************
use "STP Dataset Final.dta", clear

gen TradeBarrier = 1 if TradeBarrierCount>0
replace TradeBarrier = 0 if TradeBarrierCount==0
gen Trade_importance = ((ImportT1+ExportT1)/(ImportCountryT1+ExportCountryT1))*100
drop if ImportincreaseT1T2 ==.
gen importincrease = 1 if ImportincreaseT1T2>=0
replace importincrease = 0 if ImportincreaseT1T2<0
gen importsurge75 = 1 if ImportincreaseT1T2>=75
replace importsurge75 = 0 if ImportincreaseT1T2<75
gen importsurge45 = 1 if ImportincreaseT1T2>=45
replace importsurge45 = 0 if ImportincreaseT1T2<45
gen HomRaw = 1 if RawMaterials==1 & Rauchcon==0
replace HomRaw=0 if RawMaterials==0 | Rauchcon==1
replace HomRaw=. if RawMaterials==. | Rauchcon==.
gen TradeBarrierT1 = 1 if BarrierT1>0
replace TradeBarrierT1 = 0 if BarrierT1==0
drop if Year == 2008

heckprobit SelectiveProtection IITt1 GVC TradeBarrierT1 i.Countryid i.Sector, sel(TradeBarrier= importincrease TradeBarrierT1 i.Countryid i.Sector) vce(robust) first

heckprobit SelectiveProtection IITt1 GVC TradeBarrierT1 importsurge45 ib3.Government PTAs i.Countryid i.Sector, sel(TradeBarrier= importincrease ib3.Government TariffAHSWAAll Trade_importance TradeBarrierT1 i.Countryid i.Sector) vce(robust) first

heckprobit SelectiveProtection IITt1 GVC importsurge75 TradeBarrierT1 ib3.Government PTAs  i.Countryid i.Sector, sel(TradeBarrier=  importincrease IITt1 GVC ib3.Government TariffAHSWAAll Trade_importance HomRaw TradeBarrierT1 i.Countryid i.Sector) vce(robust) first

************************* Table A.8 ******************************************** 
use "STP Dataset Final.dta", clear

gen TradeBarrier = 1 if TradeBarrierCount>0
replace TradeBarrier = 0 if TradeBarrierCount==0
gen Trade_importance = ((ImportT1+ExportT1)/(ImportCountryT1+ExportCountryT1))*100
drop if ImportincreaseT1T2 ==.
gen importincrease = 1 if ImportincreaseT1T2>=0
replace importincrease = 0 if ImportincreaseT1T2<0
gen importsurge75 = 1 if ImportincreaseT1T2>=75
replace importsurge75 = 0 if ImportincreaseT1T2<75
gen importsurge45 = 1 if ImportincreaseT1T2>=45
replace importsurge45 = 0 if ImportincreaseT1T2<45
gen HomRaw = 1 if RawMaterials==1 & Rauchcon==0
replace HomRaw=0 if RawMaterials==0 | Rauchcon==1
replace HomRaw=. if RawMaterials==. | Rauchcon==. 

heckprobit SelectiveProtection IITt1 GVC i.Countryid i.Sector, sel(TradeBarrier= importincrease i.Countryid i.Sector) vce(cl Year) first

heckprobit SelectiveProtection IITt1 GVC importsurge45 ib3.Government PTAs i.Countryid i.Sector, sel(TradeBarrier= importincrease ib3.Government TariffAHSWAAll Trade_importance i.Countryid i.Sector) vce(cl Year) first

heckprobit SelectiveProtection IITt1 GVC importsurge75  ib3.Government PTAs  i.Countryid i.Sector, sel(TradeBarrier=  importincrease IITt1 GVC ib3.Government TariffAHSWAAll Trade_importance HomRaw i.Countryid i.Sector) vce(cl Year) first

************************* Table A.9 ********************************************
use "STP Dataset Final.dta", clear

gen TradeBarrier = 1 if TradeBarrierCount>0
replace TradeBarrier = 0 if TradeBarrierCount==0
gen Trade_importance = ((ImportT1+ExportT1)/(ImportCountryT1+ExportCountryT1))*100
drop if ImportincreaseT1T2 ==.
gen importincrease = 1 if ImportincreaseT1T2>=0
replace importincrease = 0 if ImportincreaseT1T2<0
gen importsurge75 = 1 if ImportincreaseT1T2>=75
replace importsurge75 = 0 if ImportincreaseT1T2<75
gen importsurge45 = 1 if ImportincreaseT1T2>=45
replace importsurge45 = 0 if ImportincreaseT1T2<45
gen HomRaw = 1 if RawMaterials==1 & Rauchcon==0
replace HomRaw=0 if RawMaterials==0 | Rauchcon==1
replace HomRaw=. if RawMaterials==. | Rauchcon==.
drop if TradeBarrier == 0

reg SelectiveProtection IITt1 GVC importincrease i.Countryid i.Sector, vce(robust) 

reg SelectiveProtection IITt1 GVC importsurge45 ib3.Government PTAs importincrease TariffAHSWAAll Trade_importance i.Countryid i.Sector, vce(robust) 

reg SelectiveProtection IITt1 GVC importsurge75 ib3.Government PTAs importincrease TariffAHSWAAll Trade_importance HomRaw i.Countryid i.Sector, vce(robust) 

************************* Table A.10 ********************************************
use "STP Dataset Final.dta", clear

gen TradeBarrier = 1 if TradeBarrierCount>0
replace TradeBarrier = 0 if TradeBarrierCount==0
gen Trade_importance = ((ImportT1+ExportT1)/(ImportCountryT1+ExportCountryT1))*100
drop if ImportincreaseT1T2 ==.
gen importincrease = 1 if ImportincreaseT1T2>=0
replace importincrease = 0 if ImportincreaseT1T2<0
gen importsurge75 = 1 if ImportincreaseT1T2>=75
replace importsurge75 = 0 if ImportincreaseT1T2<75
gen importsurge45 = 1 if ImportincreaseT1T2>=45
replace importsurge45 = 0 if ImportincreaseT1T2<45
gen HomRaw = 1 if RawMaterials==1 & Rauchcon==0
replace HomRaw=0 if RawMaterials==0 | Rauchcon==1
replace HomRaw=. if RawMaterials==. | Rauchcon==.
gen IIT_GVC = IITt1 * GVC

heckprobit SelectiveProtection IITt1 GVC IIT_GVC i.Countryid i.Sector, sel(TradeBarrier= importincrease i.Countryid i.Sector) vce(robust) first

heckprobit SelectiveProtection IITt1 GVC IIT_GVC importsurge45 ib3.Government PTAs i.Countryid i.Sector, sel(TradeBarrier= importincrease ib3.Government TariffAHSWAAll Trade_importance i.Countryid i.Sector) vce(robust) first

heckprobit SelectiveProtection IITt1 GVC IIT_GVC importsurge75 ib3.Government PTAs  i.Countryid i.Sector, sel(TradeBarrier=  importincrease IITt1 GVC ib3.Government TariffAHSWAAll HomRaw Trade_importance i.Countryid i.Sector) vce(robust) first